package me.sdevil507.org.repository;

import me.sdevil507.org.po.OrgRoleResourceRelPo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

public interface OrgRoleResourceRelRepository extends JpaRepository<OrgRoleResourceRelPo, Long>, JpaSpecificationExecutor<OrgRoleResourceRelPo>, QuerydslPredicateExecutor<OrgRoleResourceRelPo> {

    @Transactional(rollbackFor = Exception.class)
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true, value = "delete from biz_org_role_res_rel pr where pr.role_id=:roleId")
    void deleteByRoleId(@Param("roleId") Long roleId);

}